' + item.title + '
'; themedItem += '' + item.snippet + '
(function ($) { //global var menuIsShowing = false; //menu is displayed after the whatson ajax callback has finished, call more results could trigger the menu to display again //FUNCTION to build the search menu function bfi_build_search_menu() { var menuItems = ''; //display anchor menu if (menuIsShowing == false) { //find all the anchors to build up a menu list $('h2.section-title').each(function() { var menuTitle = ''; var blockId = ''; totalResultsCount = 0; var $this = $(this); //get the block title menuTitle = $this.text(); //get the block id this block title sits in blockId = $this.attr('id'); //get the total number of results per section if available var $subsections = $this.siblings('.bfi-search-result-group').children('.bfi-more-search-results-info'); $subsections.each(function() { // add the total number of results per subsection totalResultsCount += parseInt($(this).children('.number-of-results').text()); }); //build up the menu list menuItems += Drupal.theme('bfiSearchMenuItem', blockId, menuTitle, totalResultsCount); }); //if there are some menu items then display them if (menuItems) { menuIsShowing = true; //menu has been shown, so any more ajax calls wont set it again $('div#search-results-menu').html(Drupal.theme('bfiSearchMenu', menuItems)); //bind a click event to each nav item $('.bfi-search-nav').bind('click', function() { var $this = $(this); //get this menu items block id which matches the block id to scroll to menuBlockId = $this.attr('data-block-id'); //scroll to the h2 id $.scrollTo('#' + menuBlockId, 800); }); } } } //THEME for anchor menu Drupal.theme.prototype.bfiSearchMenu = function(menuItems) { return '
'; } //THEME for anchor item Drupal.theme.prototype.bfiSearchMenuItem = function(blockId, menuTitle, totalResultsCount) { var resultsOutput = ''; if (totalResultsCount) { resultsOutput = ' (' + totalResultsCount + ')'; } return '' + item.snippet + '